<!DOCTYPE html>
<html>
<head>
    <title>工装清单</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.erpCode" @on-enter="query" placeholder="系统编码"></i-input>
                </i-col>
                <i-col span="4">
                    <i-input v-model="q.name" @on-enter="query" placeholder="名称"></i-input>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <table id="jqGrid"></table>
    </div>
</div>

<script>
    $(function () {
        $("#jqGrid").Grid({ url: '../toolsstock/list',
            colModel: [
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
                {label: '名称', name: 'name', index: 'NAME', width: 80},
                {label: '系统编码', name: 'erpCode', index: 'ERP_CODE', width: 80},
                {label: '入库单号', name: 'inNo', index: 'IN_NO', width: 80},
                {label: '来源', name: 'resources', index: 'RESOURCES', width: 80, formatter: function (value) {
                        var res = sysEnums.RESOURCES_TYPE[value];
                        if (!res) {
                            res = "暂无数据";
                        }
                        return res;
                    }},
                {label: '货位', name: 'cargoLocation', index: 'CARGO_LOCATION', width: 80},
                {label: '仓库', name: 'workshop', index: 'WORKSHOP', width: 80},
                {label: '单价', name: 'price', index: 'PRICE', width: 80},
                {label: '单位', name: 'unit', index: 'UNIT', width: 80},
                {label: '规格', name: 'specs', index: 'SPECS', width: 80},
                {label: '入库数量', name: 'inNum', index: 'IN_NUM', width: 80},
                {label: '生产厂家', name: 'factory', index: 'FACTORY', width: 80},
                {label: '所属工装', name: 'belongTools', index: 'BELONG_TOOLS', width: 80},
                {label: '所用工序', name: 'useWorkProcedure', index: 'USE_WORK_PROCEDURE', width: 80},
                {
                    label: '入库日期', name: 'inTime', index: 'IN_TIME', width: 80, formatter: function (value) {
                        return transDate(value, 'yyyy-MM-dd')
                    }
                },
                {label: '安全库存', name: 'safeStock', index: 'SAFE_STOCK', width: 80},
                {label: '库存数量', name: 'stockNum', index: 'STOCK_NUM', width: 80},
                {label: '备注信息', name: 'remark', index: 'REMARK', width: 80},
                /*
                  {label: '审批人', name: 'approvalUser', index: 'APPROVAL_USER', width: 80},
                  {label: '审批时间', name: 'approvalTime', index: 'APPROVAL_TIME', width: 80},
                  {label: '使用单位', name: 'useUnit', index: 'USE_UNIT', width: 80},
                  {label: '修改时间', name: 'updateTime', index: 'UPDATE_TIME', width: 80},
                  {label: '修改人', name: 'updateUser', index: 'UPDATE_USER', width: 80},
                  {label: '操作人', name: 'createUser', index: 'CREATE_USER', width: 80},
                  {label: '操作时间', name: 'createTime', index: 'CREATE_TIME', width: 80},
                  {label: '删除标识', name: 'delFlag', index: 'DEL_FLAG', width: 80},*/
            ]
        });
    });

    let vm = new Vue({
        el: '#rrapp',
        data: {
            q: {
                erpCode: '',
                name:''
            }
        },
        methods: {
            query: function () {
                vm.reload();
            },
            reload: function (event) {
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: vm.q,
                    page: page
                }).trigger("reloadGrid");
                vm.handleReset('formValidate');
            },
            reloadSearch: function () {
                vm.q = {
                    erpCode: '',
                    name: ''
                };
                vm.reload();
            },
            handleSubmit: function (name) {
                handleSubmitValidate(this, name, function () {
                    vm.saveOrUpdate()
                });
            },
            handleReset: function (name) {
                handleResetForm(this, name);
            }
        }
    });

    var getSparePart = function () {
        let result = getSelectedRowData("#jqGrid");
        var id = result.id;
        if (id == null) {
            return false;
        } else {
            return result;
        }
    }
</script>
</body>
</html>
